import KoaRouter from 'koa-router';
const router = new KoaRouter({ prefix: '/sys/dict' });
import { auth, hadAdminPermission } from '../middleware/auth.middleware';
import { verifyPageSize } from '../middleware/pagesize.middleware';
import { DictDataValidator, DictTypeValidator, verifyDict } from '../middleware/dict.middleware';
import dictController from '../controller/dict.controller';

router.use(auth);
router.use(hadAdminPermission);
//创建字典类型
router.post('/type/create',DictTypeValidator,verifyDict,dictController.createType)
//删除字典类型
router.delete('/type/delete',dictController.deleteType)
//更新字典类型
router.put('/type/update',dictController.updateType)
//查询字典列表
router.get('/type/queryList',verifyPageSize,dictController.queryTypeList)

//创建字典值
router.post('/data/create',DictDataValidator,verifyDict,dictController.createData)
//删除字典值
router.delete('/data/delete',dictController.deleteData)
//更新字典值
router.put('/data/update',dictController.updateData)
//查询字典值列表
router.get('/data/queryList',verifyPageSize,dictController.queryDataList)

export default router;